package WaiBao;

import java.util.Arrays;

public class LiuShiQing {
    public static void main(String[] args) {
        String[] name = {"张德宝(班长)","赵星星(团支书)", "小李(学习委员)","李泽楷(体育委员)", "李浩男(纪律委员)", "易学习", "李伟明", "王彦斌", "王彦博", "张天翼", "李亚东", "吴金玉",
                "张起灵", "张雅东", "林黛玉", "王凯凯", "李三娘", "李二牛", "刘大壮", "刘峰", "李海", "萧敬腾", "張伯倫", "李涵", "孙尚香", "王村乡", "张德贵", "孙子涵",
                "唐艺昕", "刘诗情(学生)"};//考生本人:刘诗情(学生)
        int[] age = {20, 18, 19, 20, 19, 21, 19, 21, 19, 19, 18, 20, 18, 20, 20, 19, 21, 18, 20, 18, 19, 19, 21, 20, 20,21, 20, 21, 20, 19};//最后一位：考生年龄:19



        double[] douying1 = {85, 75, 85, 94, 69, 67, 78, 89, 85, 80, 71, 87, 85, 85, 62, 68, 99, 90, 76, 88, 92, 71, 92, 64, 75, 74, 90, 74, 84, 95};
        double[] douying2 = {76, 87, 74, 76, 78, 75, 74, 65, 84, 70, 95, 77, 76, 95, 76, 65, 76, 79, 66, 68, 75, 70, 74, 84, 75, 88, 94, 78, 85, 95};
        double[] douying3 = {83, 77, 86, 85, 77, 66, 79, 69, 85, 83, 93, 87, 85, 65, 65, 68, 69, 96, 94, 93, 92, 81, 69, 75, 76, 84, 73, 71, 88, 96};

        double zhifu1;//代表每个学生的总分
        double zhifu2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            zhifu1 = douying1[i] + douying2[i] + douying3[i];
//            zhifu2 = (zhifu1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + zhifu1);
//            System.out.println(name[i] + "的平均分为:" + zhifu2);
//        }


        double taote1 = 0,taote2 = 0;
        double[] taobao = new double[30];
//        for (int i = 0; i < 30; i++) {
//            taote1= douying1[i] + douying2[i] +douying3[i];
//            taote2 = (taote1 * 1.0) / 3;
//            taobao[i] =taote2;
//        }
//
//        for (int i = 0; i < taobao.length - 1; i++) {
//            for (int j = 0; j < taobao.length - i - 1; j++) {
//                if ( taobao[j] < taobao[j + 1]) {
//                    double tep = taobao[j];
//                    taobao[j] =  taobao[j + 1];
//                    taobao[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println( taobao[i]);
//        }



        double xiejia1 = 0, xiejia2 = 0, xiejia3 = 0;//计算每门课的平均分
        double baiqiang1 = 0,baiqiang2 = 0, baiqiang3 = 0;//计算每门课标准差
        double shuini1 = 0, shuini2 = 0, shuini3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <douying1.length; i++) {
            he += douying1[i];
        }
        xiejia1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + xiejia1);
        double Sum = 0;
        for (int i = 0; i <douying2.length; i++) {
            Sum += douying2[i];
        }
        xiejia2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" + xiejia2);
        double sum = 0;
        for (int i = 0; i < douying3.length; i++) {
            sum += douying3[i];
        }
        xiejia3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" +xiejia3);


        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < douying1.length; i++) {
            c1 += (douying1[i] - xiejia1) * (douying1[i] -xiejia1);
        }
        baiqiang1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + baiqiang1);
        for (int i = 0; i <douying2.length; i++) {
            c2 += (douying2[i] - xiejia2) * (douying2[i] - xiejia2);
        }
        baiqiang2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" +baiqiang2);

        for (int i = 0; i <douying3.length; i++) {
            c3 += (douying3[i] - xiejia3) * (douying3[i] - xiejia3);
        }
        baiqiang3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" + baiqiang3);
//////
////
////
        Arrays.sort(douying1);
        Arrays.sort(douying2);
        Arrays.sort(douying3);
        shuini1 = (douying1[14] + douying2[15]) * 1.0 / 2;
        shuini2 = (douying2[14] + douying2[15]) * 1.0 / 2;
        shuini3 = (douying3[14] + douying3[15]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" +  shuini1);
        System.out.println("物理化学的中位数为:" +  shuini2);
        System.out.println("电子与电工技术的中位数为:" + shuini3);



    }
}
